﻿#include <stdio.h>
#include <hiredis/hiredis.h>
#include <string>
#include "RedisMgr.h"
#include "Logger.h"
#include<assert.h>
void TestRedisMgr() {
    //assert(RedisMgr::GetInstance()->Connect("127.0.0.1", 6380));
    //assert(RedisMgr::GetInstance()->Auth("123456"));
    assert(RedisMgr::GetInstance()->Set("blogwebsite", "llfc.club"));
    std::string value = "";
    assert(RedisMgr::GetInstance()->Get("blogwebsite", value));
    assert(RedisMgr::GetInstance()->Get("nonekey", value) == false);
    assert(RedisMgr::GetInstance()->HSet("bloginfo", "blogwebsite", "llfc.club"));
    assert(RedisMgr::GetInstance()->HGet("bloginfo", "blogwebsite") != "");
    assert(RedisMgr::GetInstance()->ExistsKey("bloginfo"));
    assert(RedisMgr::GetInstance()->Del("bloginfo"));
    assert(RedisMgr::GetInstance()->Del("bloginfo"));
    assert(RedisMgr::GetInstance()->ExistsKey("bloginfo") == false);
    assert(RedisMgr::GetInstance()->LPush("lpushkey1", "lpushvalue1"));
    assert(RedisMgr::GetInstance()->LPush("lpushkey1", "lpushvalue2"));
    assert(RedisMgr::GetInstance()->LPush("lpushkey1", "lpushvalue3"));
    assert(RedisMgr::GetInstance()->RPop("lpushkey1", value));
    assert(RedisMgr::GetInstance()->RPop("lpushkey1", value));
    assert(RedisMgr::GetInstance()->LPop("lpushkey1", value));
    assert(RedisMgr::GetInstance()->LPop("lpushkey2", value) == false);
    RedisMgr::GetInstance()->Close();
}
int main() {
    // 指定日志文件路径）
    Logger::Init("server_logs/log_%N.log"); // %N 会自动替换为序号（滚动日志）
    // 开发环境设置为 Debug 级别，生产环境设为 Info
    Logger::SetLevel(boost::log::trivial::debug);
    LOG_INFO << "LOGGER TEST SUCCESS!";
	TestRedisMgr();
    return 0;
}